feat: update token metadata service to include RWA data in API requests#7595
Conversation
- Modified token service URLs to append `includeRwaData=true` for fetching token data. - Updated related test cases to reflect the new API request structure. - Adjusted `TokenListController` to support RWA data in token list retrieval. This change enhances the token service functionality by allowing the inclusion of RWA data in the responses, improving the overall data richness for consumers.
| // 4 Hour Interval Cache Refresh Threshold | ||
| const DEFAULT_INTERVAL = 4 * 60 * 60 * 1000; | ||
| const DEFAULT_THRESHOLD = 4 * 60 * 60 * 1000; |
There was a problem hiding this comment.
As discussed in slack - we have modified the cache interval from 24 hours to 4 hours.
We should monitor if this causes any performance hits - (mostly from the large writes to state)
There was a problem hiding this comment.
I thought we wanted to pass this in constructor client side instead of updating the controller's default values?
There was a problem hiding this comment.
meeeeh I don't mind either or... But this would minimise client changes required. Open to options on this :)
There was a problem hiding this comment.
Hmmm agree, tbh doing it on constructor seems to be the proper way to go about this.
Doing it in this controller is less changes for sure;
I don't mind tbh, if you feel like you prefer this one, happy to approve 🙏
There was a problem hiding this comment.
Sweet, lets do it inside the controller for now -- less changes that devs need to make. We can treat the ones inside the constructor as "overrides" if it needs to be overridden.
| return `/tokens/${convertHexToDecimal( | ||
| chainId, | ||
| )}?occurrenceFloor=3&includeNativeAssets=false&includeTokenFees=false&includeAssetType=false&includeERC20Permit=false&includeStorage=false`; | ||
| )}?occurrenceFloor=3&includeNativeAssets=false&includeTokenFees=false&includeAssetType=false&includeERC20Permit=false&includeStorage=false&includeRwaData=true`; |
There was a problem hiding this comment.
We have a PR to update to the new endpoint #7572
However this is postponed to reduce the scope of changes for the RWA feature launch.
832bbcc to
cfb24ed
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
|
Preview build here: MetaMask/metamask-extension#39129 |
|
Demo on extension with tokens that have RWA data. |
Explanation
includeRwaData=truefor fetching token data.TokenListControllerto support RWA data in token list retrieval.This change enhances the token service functionality by allowing the inclusion of RWA data in the responses, improving the overall data richness for consumers.
References
Checklist
Note
Adds RWA metadata support to token list retrieval and shortens cache refresh window.
includeRwaData=trueto token list API calls infetchTokenListByChainId; update tests accordinglyTokenListControllertoken type with optionalrwaData(TokenRwaData)TokenListControllercache interval/threshold from 24h to 4hCHANGELOG.mdWritten by Cursor Bugbot for commit cb897e9. This will update automatically on new commits. Configure here.